package com.baidu.structure.adapter;


import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;

import java.util.ArrayList;

/**
 * Created by sunmo on 2016/10/23.
 */
public class BasicPagerAdapter extends FragmentStatePagerAdapter {
    private ArrayList<Fragment> list;
    private String[] title;

    public BasicPagerAdapter(FragmentManager fm, ArrayList<Fragment> list, String[] title) {
        super(fm);
        this.list = list;
        this.title = title;
    }

    @Override
    public Fragment getItem(int position) {
        return list == null ? null : list.get(position);
    }

    @Override
    public int getCount() {
        return list == null ? 0 : list.size();
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return title == null ? super.getPageTitle(position) : title[position];
    }
}